package com.hsnn.medstgmini.pro.base.controller;

import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.base.dict.model.form.DicAreaForm;
import com.hsnn.medstgmini.base.dict.service.DicAreaManager;
import com.hsnn.medstgmini.base.dict.service.DicSysManager;
import com.hsnn.medstgmini.base.std.model.StdHealthbureau;
import com.hsnn.medstgmini.pro.base.service.AnaDruginfoManager;
import com.hsnn.medstgmini.service.DynamicSelectManager;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.trading.catalog.service.HospCatalogManager;
import com.hsnn.medstgmini.util.AreaUtil;
import com.hsnn.medstgmini.util.DbUtil;
import com.hsnn.medstgmini.util.ExcelUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;
import com.hsnn.medstgmini.util.SelectForm;

/**
 * @category 采购统计
 * @author 应晓川
 * @date 2015年12月1日10:16:59
 */
@Controller
@RequestMapping("/anaDruginfo")
public class AnaDruginfoController {

	private static final Logger log = Logger.getLogger(AnaDruginfoController.class);
	@Autowired
	private  AnaDruginfoManager anaDruginfoManager;
	
	@Autowired
	private HospCatalogManager hospCatalogManager;
	
	@Autowired
	private DynamicSelectManager selectManager;
	
	@Autowired
	private HttpServletRequest request;

	
	@Value("#{sysProp['system.province']}")
    private String sysProvince;
	
	@Autowired
	private DicSysManager dicSysManager;
	
	@Autowired
	private DicAreaManager dicAreaManager;
	
	/**
	 * @category 按时间统计
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toAnaByTime")
	public String toAnaByTime() {
		return "/pro/base/anaDruginfo/anaByTime";
	}
	@ResponseBody
	@RequestMapping("/getAnaByTime")
	public Pagination getAnaByTime() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			
			String starttime = request.getParameter("starttime");
			if (StringUtils.isNotBlank(starttime)){
				starttime = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(starttime));
				page.getConditions().put("starttime", starttime);
			}
			
			String endtime = request.getParameter("endtime");
			if (StringUtils.isNotBlank(endtime)){
				endtime = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(endtime));
				page.getConditions().put("endtime", endtime);
			}
			
			page = anaDruginfoManager.getAnaListByTime(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按医院统计
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toAnaByHosp")
	public String toAnaByHosp() {
		return "/pro/base/anaDruginfo/anaByHosp";
	}
	@ResponseBody
	@RequestMapping("/getAnaByHosp")
	public Pagination getAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}

	/**
	 * @category 按地区统计
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toAnaByArea")
	public String toAnaByArea() {
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		return "/pro/base/anaDruginfo/anaByArea";
	}
	@ResponseBody
	@RequestMapping("/getAnaByArea")
	public Pagination getAnaByArea() {
		Pagination page = new Pagination(request);
		try {
			page.getConditions().put("area1", request.getParameter("area1"));
			page.getConditions().put("area2", request.getParameter("area2"));
			page.getConditions().put("area3", request.getParameter("area3"));
			String startDay = request.getParameter("startDay");
			if (StringUtils.isNotBlank(startDay)){
				startDay = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(startDay));
			}
			page.getConditions().put("startDay", startDay);
			String endDay = request.getParameter("endDay");
			if (StringUtils.isNotBlank(endDay)){
				endDay = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(endDay));
			}
			page.getConditions().put("endDay", endDay);
			page = anaDruginfoManager.getAnaByArea(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * 
	 *@category 药品采购统计,跳向按地区查询页面（年）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:01:14
	 *@param 
	 *@return String
	 */
	@RequestMapping("/toAnaByAreaWithYear")
	public String toAnaByAreaWithYear(String date){
		request.setAttribute("lastYear", ParseDate.addYear(new Date(), -7));
		request.setAttribute("lastYear2", ParseDate.addYear(new Date(), -1));
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		
		request.setAttribute("date", date);
		if (Constants.HSZX == user.getType()) {
			return "/pro/base/anaDruginfo/anaByAreaAllYear";
		}else {
			return "/pro/base/anaDruginfo/anaByAreaWithYear";
		}
		
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（年）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getAnaByAreaWithYear")
	@ResponseBody
	public Pagination getAnaByAreaWithYear(String date){
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
		}
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		page.getConditions().put("startYear", request.getParameter("startYear"));
		page.getConditions().put("endYear", request.getParameter("endYear"));
		
		if(!StringUtils.isNotBlank(request.getParameter("startYear")) && !StringUtils.isNotBlank(request.getParameter("endYear"))) {//判断是否选择时间
			page.getConditions().put("startYear", date);
			page.getConditions().put("endYear", date);
		}
		return anaDruginfoManager.getAnaByAreaWithYear(page);
	}
	
	
	
	
	/**
	 * 
	 *@category 药品采购统计,跳向按地区查询页面（季）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:01:14
	 *@param 
	 *@return String
	 */
	@RequestMapping("/toAnaByAreaWithSea")
	public String toAnaByAreaWithSea(String date){
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		Calendar calendar = new GregorianCalendar(); 
        calendar.setTime(ParseDate.addMonth(new Date(), -3));
        int month = calendar.get(Calendar.MONTH) + 1;
        String sea = "";
        if(month == 1 || month ==2 || month ==3){
       	 sea = calendar.get(Calendar.YEAR)+"年第01季度";
        }
        else if(month == 4 || month ==5 || month ==6){
       	 sea = calendar.get(Calendar.YEAR)+"年第02季度";
        }
        else if(month == 7 || month ==8 || month ==9){
       	 sea = calendar.get(Calendar.YEAR)+"年第03季度";
        }
        else if(month == 10 || month ==11 || month ==12){
       	 sea = calendar.get(Calendar.YEAR)+"年第04季度";
        }
		
		calendar = new GregorianCalendar(); 
        calendar.setTime(ParseDate.addMonth(new Date(), -21));
        month = calendar.get(Calendar.MONTH) + 1;
        String sea2 = "";
        if(month == 1 || month ==2 || month ==3){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第01季度";
        }
        else if(month == 4 || month ==5 || month ==6){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第02季度";
        }
        else if(month == 7 || month ==8 || month ==9){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第03季度";
        }
        else if(month == 10 || month ==11 || month ==12){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第04季度";
        }
		
		request.setAttribute("lastSea",sea2 +"至"+ sea);
		request.setAttribute("lastSea2", sea);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		
		request.setAttribute("date", date);
		if (Constants.HSZX == user.getType()) {
			return "/pro/base/anaDruginfo/anaByAreaAllSea";
		}else {
			return "/pro/base/anaDruginfo/anaByAreaWithSea";
		}
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（季）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getAnaByAreaWithSea")
	@ResponseBody
	public Pagination getAnaByAreaWithSea(String date){
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
		}
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		String startSea = request.getParameter("startSea");
		if (StringUtils.isNotBlank(startSea)){
			startSea = startSea.replace("年", "0");
			startSea = startSea.replace("季度", "");
		}
		page.getConditions().put("startSea", startSea);
		String endSea = request.getParameter("endSea");
		if (StringUtils.isNotBlank(endSea)){
			endSea = endSea.replace("年", "0");
			endSea = endSea.replace("季度", "");
		}
		page.getConditions().put("endSea", endSea);
		
		if(!StringUtils.isNotBlank(startSea) && !StringUtils.isNotBlank(endSea)) {//判断是否选择时间
			page.getConditions().put("startSea", date);
			page.getConditions().put("endSea", date);
		}
		return anaDruginfoManager.getAnaByAreaWithSea(page);
	}
	/**
	 * 
	 *@category 药品采购统计,跳向按地区查询页面（月）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:01:14
	 *@param 
	 *@return String
	 */
	@RequestMapping("/toAnaByAreaWithMon")
	public String toAnaByAreaWithMon(String date){
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		request.setAttribute("lastMonth", ParseDate.addMonth(new Date(), -7));
		request.setAttribute("lastMonth2", ParseDate.addMonth(new Date(), -1));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		
		request.setAttribute("date", date);
		if (Constants.HSZX == user.getType()) {
			return "/pro/base/anaDruginfo/anaByAreaAllMon";
		}else {
			return "/pro/base/anaDruginfo/anaByAreaWithMon";
		}
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（月）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getAnaByAreaWithMon")
	@ResponseBody
	public Pagination getAnaByAreaWithMon(String date){
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
		}
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		String startMon = request.getParameter("startMon");
		if (StringUtils.isNotBlank(startMon)){
			startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
		}
		page.getConditions().put("startMon", startMon);
		String endMon = request.getParameter("endMon");
		if (StringUtils.isNotBlank(endMon)){
			endMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endMon));
		}
		page.getConditions().put("endMon", endMon);
		
		if(!StringUtils.isNotBlank(startMon) && !StringUtils.isNotBlank(endMon)) {//判断是否选择时间
			page.getConditions().put("startMon", date);
			page.getConditions().put("endMon", date);
		}
		
		return anaDruginfoManager.getAnaByAreaWithMon(page);
	}
	
	/**
	 * @category 按医院统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toYearAnaByHosp")
	public String toYearAnaByHosp(String date) {
		request.setAttribute("lastYear", ParseDate.addYear(new Date(), -1));
		request.setAttribute("date", date);
		return "/pro/base/anaDruginfo/yearAnaByHosp";
	}
	
	@ResponseBody
	@RequestMapping("/getYearAnaByHosp")
	public Pagination getYearAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getYearAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按医院统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toSeaAnaByHosp")
	public String toSeaAnaByHosp(String date) {
		   Calendar calendar = new GregorianCalendar(); 
	        calendar.setTime(ParseDate.addMonth(new Date(), -3));
	        int month = calendar.get(Calendar.MONTH) + 1;
	        String sea = "";
	        if(month == 1 || month ==2 || month ==3){
	       	 sea = calendar.get(Calendar.YEAR)+"年第01季度";
	        }
	        else if(month == 4 || month ==5 || month ==6){
	       	 sea = calendar.get(Calendar.YEAR)+"年第02季度";
	        }
	        else if(month == 7 || month ==8 || month ==9){
	       	 sea = calendar.get(Calendar.YEAR)+"年第03季度";
	        }
	        else if(month == 10 || month ==11 || month ==12){
	       	 sea = calendar.get(Calendar.YEAR)+"年第04季度";
	        }
	        request.setAttribute("date",date);
			request.setAttribute("lastSea",sea);
		return "/pro/base/anaDruginfo/seaAnaByHosp";
	}
	
	@ResponseBody
	@RequestMapping("/getSeaAnaByHosp")
	public Pagination getSeaAnaByHosp() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getSeaAnaByHosp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按医院统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toMonthAnaByHosp")
	public String toMonthAnaByHosp(String date) {
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
		request.setAttribute("provinceName", area.get("area_name"));
		request.setAttribute("lastMonth2", ParseDate.addMonth(new Date(), -1));
		request.setAttribute("date",date);
		List<SelectForm> list = selectManager.getDiSys("002");
		request.setAttribute("list", list);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			DicAreaForm daf= dicAreaManager.getDicAreaById(areaId);
			request.setAttribute("daf", daf);
		}
		return "/pro/base/anaDruginfo/monthAnaByHosp";
	}
	@RequestMapping("/getMonthAnaByHosp")
	@ResponseBody
	public Pagination getMonthAnaByHosp(String date){
		Pagination page = new Pagination(request);
		String hospName = request.getParameter("hospName");
		page.getConditions().put("hospName", hospName);
		String hospClassifys = request.getParameter("hospClassifys");
		page.getConditions().put("hospClassifys", hospClassifys);
		String hospType = request.getParameter("hospType");
		page.getConditions().put("hospType", hospType);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
		}
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		String startMon = request.getParameter("startMon");
		if (StringUtils.isNotBlank(startMon)){
			startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
		}
		page.getConditions().put("startMon", startMon);
		String endMon = request.getParameter("endMon");
		if (StringUtils.isNotBlank(endMon)){
			endMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endMon));
		}
		page.getConditions().put("endMon", endMon);
		
		if(!StringUtils.isNotBlank(startMon) && !StringUtils.isNotBlank(endMon)) {//判断是否选择时间
			page.getConditions().put("startMon", date);
			page.getConditions().put("endMon", date);
		}
		page.getConditions().put("Paging", "Paging");
		return anaDruginfoManager.getMonthAnaByHosp(page);
	}
	
	
	
	////////////////////////////////////////////////////////////////////////
	/**
	 * @category 按地区统计
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toAnaCompinfoByArea")
	public String toAnaCompinfoByArea() {
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		return "/pro/base/anaDruginfo/anaCompinfoByArea";
	}
	@ResponseBody
	@RequestMapping("/getAnaCompinfoByArea")
	public Pagination getAnaCompinfoByArea() {
		Pagination page = new Pagination(request);
		try {
			page.getConditions().put("area1", request.getParameter("area1"));
			page.getConditions().put("area2", request.getParameter("area2"));
			page.getConditions().put("area3", request.getParameter("area3"));
			String startDay = request.getParameter("startDay");
			if (StringUtils.isNotBlank(startDay)){
				startDay = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(startDay));
			}
			page.getConditions().put("startDay", startDay);
			String endDay = request.getParameter("endDay");
			if (StringUtils.isNotBlank(endDay)){
				endDay = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(endDay));
			}
			page.getConditions().put("endDay", endDay);
			page = anaDruginfoManager.getAnaCompinfoByArea(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * 
	 *@category 药品采购统计,跳向按地区查询页面（年）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:01:14
	 *@param 
	 *@return String
	 */
	@RequestMapping("/toAnaCompinfoByAreaWithYear")
	public String toAnaCompinfoByAreaWithYear(String compCode){
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		request.setAttribute("compCode", compCode);
		return "/pro/base/anaDruginfo/anaCompinfoByAreaWithYear";
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（年）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getAnaCompinfoByAreaWithYear")
	@ResponseBody
	public Pagination getAnaCompinfoByAreaWithYear(String compCode){
		Pagination page = new Pagination(request);
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		page.getConditions().put("startYear", request.getParameter("startYear"));
		page.getConditions().put("endYear", request.getParameter("endYear"));
		if(!StringUtils.isNotBlank(compCode)) {
			compCode = request.getParameter("compCode");
			page.getConditions().put("compCode", compCode);
		}else {
			page.getConditions().put("compCode", compCode);
		}
		return anaDruginfoManager.getAnaCompinfoByAreaWithYear(page);
	}
	
	
	
	
	/**
	 * 
	 *@category 药品采购统计,跳向按地区查询页面（季）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:01:14
	 *@param 
	 *@return String
	 */
	@RequestMapping("/toAnaCompinfoByAreaWithSea")
	public String toAnaCompinfoByAreaWithSea(String compCode){
		request.setAttribute("province", sysProvince);
		Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
		request.setAttribute("provinceName", area.get("area_name"));
		request.setAttribute("compCode", compCode);
		return "/pro/base/anaDruginfo/anaCompinfoByAreaWithSea";
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（季）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getAnaCompinfoByAreaWithSea")
	@ResponseBody
	public Pagination getAnaCompinfoByAreaWithSea(String compCode){
		Pagination page = new Pagination(request);
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		String startSea = request.getParameter("startSea");
		if (StringUtils.isNotBlank(startSea)){
			startSea = startSea.replace("年", "0");
			startSea = startSea.replace("季度", "");
		}
		page.getConditions().put("startSea", startSea);
		String endSea = request.getParameter("endSea");
		if (StringUtils.isNotBlank(endSea)){
			endSea = endSea.replace("年", "0");
			endSea = endSea.replace("季度", "");
		}
		page.getConditions().put("endSea", endSea);
		if(!StringUtils.isNotBlank(compCode)) {
			compCode = request.getParameter("compCode");
			page.getConditions().put("compCode", compCode);
		}else {
			page.getConditions().put("compCode", compCode);
		}
		return anaDruginfoManager.getAnaCompinfoByAreaWithSea(page);
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据（月）
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getAnaCompinfoByAreaWithMon")
	@ResponseBody
	public Pagination getAnaCompinfoByAreaWithMon(){
		Pagination page = new Pagination(request);
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		page.getConditions().put("date", request.getParameter("date"));
		page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
		anaDruginfoManager.getAnaCompinfoByAreaWithMon(page);
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息（月度）
	 * @date 2015年12月03日
	 * @return
	 */
	@RequestMapping("/toAnaByAllMonth")
	public String toAnaByAllMonth() {
		
		request.setAttribute("lastMonth", ParseDate.addMonth(new Date(), -7));
		request.setAttribute("lastMonth2", ParseDate.addMonth(new Date(), -1));
		return "/pro/base/anaDruginfo/anaByAllMon";
	}
	
	/**
	 * @category 采购总体情况汇总信息（月度）
	 * @date 2015年12月022日
	 * @author lil
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getAnaByAllMonth")
	public Pagination getAnaByAllMonth() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			
			String starttime = request.getParameter("starttime");
			if (StringUtils.isNotBlank(starttime)){
				starttime = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(starttime)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(starttime));
				page.getConditions().put("starttime", starttime);
			}
			
			String endtime = request.getParameter("endtime");
			if (StringUtils.isNotBlank(endtime)){
				endtime = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endtime)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endtime));
				page.getConditions().put("endtime", endtime);
			}
			
			page = anaDruginfoManager.getAnaByAllMonth(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息（季度）
	 * @date 2015年12月22日
	 * @author lil
	 * @return
	 */
	@RequestMapping("/toAnaByAllSea")
	public String toAnaByTimeQuarter() {
		Calendar calendar = new GregorianCalendar(); 
        calendar.setTime(ParseDate.addMonth(new Date(), -3));
        int month = calendar.get(Calendar.MONTH) + 1;
        String sea = "";
        if(month == 1 || month ==2 || month ==3){
       	 sea = calendar.get(Calendar.YEAR)+"年第01季度";
        }
        else if(month == 4 || month ==5 || month ==6){
       	 sea = calendar.get(Calendar.YEAR)+"年第02季度";
        }
        else if(month == 7 || month ==8 || month ==9){
       	 sea = calendar.get(Calendar.YEAR)+"年第03季度";
        }
        else if(month == 10 || month ==11 || month ==12){
       	 sea = calendar.get(Calendar.YEAR)+"年第04季度";
        }
        
        calendar = new GregorianCalendar(); 
        calendar.setTime(ParseDate.addMonth(new Date(), -21));
        month = calendar.get(Calendar.MONTH) + 1;
        String sea2 = "";
        if(month == 1 || month ==2 || month ==3){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第01季度";
        }
        else if(month == 4 || month ==5 || month ==6){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第02季度";
        }
        else if(month == 7 || month ==8 || month ==9){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第03季度";
        }
        else if(month == 10 || month ==11 || month ==12){
       	 sea2 = calendar.get(Calendar.YEAR)+"年第04季度";
        }
		request.setAttribute("lastSea",sea2 + "至" +sea);
		
		return "/pro/base/anaDruginfo/anaByAllSea";
	}
	/**
	 * @category 采购总体情况汇总信息（季度）
	 * @date 2015年12月22日
	 * @author lil
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getAnaByAllSea")
	public Pagination getAnaByAllSea() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getAnaByAllSea(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息（年度）
	 * @date 2015年12月22日
	 * @author lil
	 * @return
	 */
	@RequestMapping("/toAnaByAllYear")
	public String toAnaByTimeYear() {
		request.setAttribute("lastYear", ParseDate.addYear(new Date(), -7));
		request.setAttribute("lastYear2", ParseDate.addYear(new Date(), -1));
		return "/pro/base/anaDruginfo/anaByAllYear";
	}
	
	/**
	 * @category 采购总体情况汇总信息（年度）
	 * @date 2015年12月22日
	 * @author lil
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getAnaByAllYear")
	public Pagination getAnaByAllYear() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getAnaByAllYear(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按企业统计
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toAnaByComp")
	public String toAnaByComp() {
		return "/pro/base/anaDruginfo/anaByComp";
	}
	@ResponseBody
	@RequestMapping("/getAnaByComp")
	public Pagination getAnaByComp() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 企业配送情况统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toYearAnaByComp")
	public String toYearAnaByComp(String date) {
		request.setAttribute("lastYear", ParseDate.addYear(new Date(), -1));
		request.setAttribute("date", date);
		return "/pro/base/anaDruginfo/yearAnaByComp";
	}
	
	/**
	 * @category 企业配送情况统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getYearAnaByComp")
	public Pagination getYearAnaByComp(String date) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			if(!StringUtils.isNotBlank(request.getParameter("startYear")) && !StringUtils.isNotBlank(request.getParameter("endYear"))) {//判断是否选择时间
				page.getConditions().put("startYear", date);
				page.getConditions().put("endYear", date);
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getYearAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 企业配送情况统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@RequestMapping("/toSeaAnaByComp")
	public String toSeaAnaByComp(String date) {
		Calendar calendar = new GregorianCalendar(); 
        calendar.setTime(ParseDate.addMonth(new Date(), -3));
        int month = calendar.get(Calendar.MONTH) + 1;
        String sea = "";
        if(month == 1 || month ==2 || month ==3){
       	 sea = calendar.get(Calendar.YEAR)+"年第01季度";
        }
        else if(month == 4 || month ==5 || month ==6){
       	 sea = calendar.get(Calendar.YEAR)+"年第02季度";
        }
        else if(month == 7 || month ==8 || month ==9){
       	 sea = calendar.get(Calendar.YEAR)+"年第03季度";
        }
        else if(month == 10 || month ==11 || month ==12){
       	 sea = calendar.get(Calendar.YEAR)+"年第04季度";
        }
		
		request.setAttribute("lastSea",sea);
		request.setAttribute("date", date);
		return "/pro/base/anaDruginfo/seaAnaByComp";
	}
	
	/**
	 * @category 企业配送情况统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getSeaAnaByComp")
	public Pagination getSeaAnaByComp(String date) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			if(!StringUtils.isNotBlank(request.getParameter("startSea")) && !StringUtils.isNotBlank(request.getParameter("endSea"))) {//判断是否选择时间
				page.getConditions().put("startSea", date);
				page.getConditions().put("endSea", date);
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getSeaAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按企业统计(月)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@RequestMapping("/toMonthAnaByComp")
	public String toMonthAnaByComp(String date) {
		
		request.setAttribute("lastMonth", ParseDate.addMonth(new Date(), -1));
		
		request.setAttribute("date", date);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			request.setAttribute("areaHidden","areaHidden");
		}
		return "/pro/base/anaDruginfo/monthAnaByComp";
	}
	
	/**
	 * @category 企业配送情况统计(月)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getMonthAnaByComp")
	public Pagination getMonthAnaByComp(String date) {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if(Constants.HSZX==user.getType()){
				StdHealthbureau shb = user.getInfo();
				String areaId = shb.getArea().getAreaid();
				page.getConditions().put("areaId", areaId);
			}
			
			if(!StringUtils.isNotBlank(request.getParameter("startMonth")) && !StringUtils.isNotBlank(request.getParameter("endMonth"))) {//判断是否选择时间
				page.getConditions().put("startMonth", date);
				page.getConditions().put("endMonth", date);
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getMonthAnaByComp(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	//--------------------------按药品统计start---------------------------------------------
	
	/**
	 * @category 按药品统计每日销售
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toAnaByDrugs")
	public String toAnaByDrugs() {
		return "/pro/base/anaDruginfo/anaByDrugs";
	}
	
	/**
	 * @category 根据时间查询药品销售统计汇总（每日）
	 * @date 2015-12-04
	 * @author lil
	 * @return Pagination
	 */
	@ResponseBody
	@RequestMapping("/getAnaByDrugs")
	public Pagination getAnaByDrugs() {
		Pagination page = new Pagination(request);
		try {
			DbUtil.jsonToMap(request, page);
			String starttime = request.getParameter("starttime");
			if (StringUtils.isNotBlank(starttime)){
				starttime = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(starttime));
				page.getConditions().put("starttime", starttime);
			}
			
			String endtime = request.getParameter("endtime");
			if (StringUtils.isNotBlank(endtime)){
				endtime = ParseDate.parseYMDFormat(ParseDate.fromShortFormat(endtime));
				page.getConditions().put("endtime", endtime);
			}
			page = anaDruginfoManager.getAnaByDrugs(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	
	/**
	 * @category 按药品统计月度销售
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toAnaByDrugsWithMon")
	public String toAnaByDrugsWithMon(String date) {
		request.setAttribute("lastMonth", ParseDate.addMonth(new Date(), -1));
		request.setAttribute("date",date);
		return "/pro/base/anaDruginfo/anaByDrugsWithMon";
	}
	
	/**
	 * @category 根据时间查询药品销售统计汇总（月度）
	 * @date 2015-12-04
	 * @author lil
	 * @return Pagination
	 */
	@ResponseBody
	@RequestMapping("/getAnaByDrugsWithMon")
	public Pagination getAnaByDrugsWithMon() {
		Pagination page = new Pagination(request);
		try {
			getAreaIdWithWSJ(page);
			DbUtil.jsonToMap(request, page);			
			String starttime = request.getParameter("starttime").replace("-","");
			if (StringUtils.isNotBlank(starttime)){
				page.getConditions().put("starttime", starttime);
			}
			
			String endtime = request.getParameter("endtime").replace("-","");
			if (StringUtils.isNotBlank(endtime)){
				page.getConditions().put("endtime", endtime);
			}
			page.getConditions().put("Paging", "Paging");
			page = anaDruginfoManager.getAnaByDrugsMonth(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按药品统计季度销售
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toAnaByDrugsWithSea")
	public String toAnaByDrugsWithSea(String date) {
		
        Calendar calendar = new GregorianCalendar(); 
        calendar.setTime(ParseDate.addMonth(new Date(), -3));
        int month = calendar.get(Calendar.MONTH) + 1;
        String sea = "";
        if(month == 1 || month ==2 || month ==3){
       	 sea = calendar.get(Calendar.YEAR)+"年第01季度";
        }
        else if(month == 4 || month ==5 || month ==6){
       	 sea = calendar.get(Calendar.YEAR)+"年第02季度";
        }
        else if(month == 7 || month ==8 || month ==9){
       	 sea = calendar.get(Calendar.YEAR)+"年第03季度";
        }
        else if(month == 10 || month ==11 || month ==12){
       	 sea = calendar.get(Calendar.YEAR)+"年第04季度";
        }
		
		request.setAttribute("lastSea",sea);
		request.setAttribute("date",date);
		return "/pro/base/anaDruginfo/anaByDrugsWithSea";
	}
	
	/**
	 * @category 根据时间查询药品销售统计汇总（季度）
	 * @date 2015-12-04
	 * @author lil
	 * @return Pagination
	 */
	@ResponseBody
	@RequestMapping("/getAnaByDrugsWithSea")
	public Pagination getAnaByDrugsWithSea() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getAnaByDrugsSea(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 按药品统计年度销售
	 * @date 2015年12月1日10:18:44
	 * @return
	 */
	@RequestMapping("/toAnaByDrugsWithYear")
	public String toAnaByDrugsWithYear(String date) {
		request.setAttribute("lastYear", ParseDate.addYear(new Date(), -1));
		request.setAttribute("date",date);
		return "/pro/base/anaDruginfo/anaByDrugsWithYear";
	}
	
	/**
	 * @category 根据时间查询药品销售统计汇总（年度）
	 * @date 2015-12-04
	 * @author lil
	 * @return Pagination
	 */
	@ResponseBody
	@RequestMapping("/getAnaByDrugsWithYear")
	public Pagination getAnaByDrugsWithYear() {
		Pagination page = new Pagination(request);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			DbUtil.jsonToMap(request, page);
			page = anaDruginfoManager.getAnaByDrugsYear(page);
			page.setSuccess(true);
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	//--------------------------按药品统计end---------------------------------------------
	@SuppressWarnings("rawtypes")
	public void printParams(){
		Enumeration paramNames = request.getParameterNames();
		try {
			while (paramNames.hasMoreElements()) {
				String paramName = (String) paramNames.nextElement();
				String paramValue = request.getParameter(paramName);
				log.info(paramName+":"+paramValue);
			}
		} catch (Exception e) {
			log.error("",e);
		}
	}
	/**
	 * 
	 *@category 药品按月度导出excel
	 *@author 应晓川
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithMon")
	@ResponseBody
	public Pagination exportExcelWithMon(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		String starttime = request.getParameter("starttime");
		if (StringUtils.isNotBlank(starttime)){
			starttime = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(starttime)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(starttime));
			page.getConditions().put("starttime", starttime);
		}
		String endtime = request.getParameter("endtime");
		if (StringUtils.isNotBlank(endtime)){
			endtime = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endtime)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endtime));
			page.getConditions().put("endtime", endtime);
		}
		try {
			
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			String filename = ExcelUtil.processFileName(request, "按月度统计药品采购情况");  
			getAreaIdWithWSJ(page);
			response.addHeader("Content-Disposition", "attachment;filename="+filename+".xls"); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			
			String title = "按月度统计药品采购情况";
			String[] headers =page.getConditions().get("colNames").split(",");
			String[] alias =page.getConditions().get("colModel").split(",");
			page.getConditions().remove("colNames");
			page.getConditions().remove("colModel");
			page = anaDruginfoManager.getAnaByDrugsMonth(page);
			ExcelUtil.exportExcel(page, os,title, headers, alias);
			page.setSuccess(true);
			
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 药品按季度导出excel
	 *@author 应晓川
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithSea")
	@ResponseBody
	public Pagination exportExcelWithSea(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			response.addHeader("Content-Disposition", "attachment;filename="+new String("按季度统计药品采购情况.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getAnaByDrugsSeaNoPage(page);
			String title = "按季度统计药品采购情况";
			String[] headers = {"季度","通用名","剂型","规格","转换系数","包装单位", "生产企业","药品分类","采购总金额(万)", "配送金额(万)","配送率","入库金额(万)","入库率"};
			String[] alias = {"date","drug_name","form_name","spec_name","factor","unit_name","prod_compname","drug_cat","total_amount","del_amount","del_ratio","recp_amount","recp_ratio"};
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 药品按年度导出excel
	 *@author 应晓川
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithYear")
	@ResponseBody
	public Pagination exportExcelWithYear(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			response.addHeader("Content-Disposition", "attachment;filename="+new String("按年度统计药品采购情况.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getAnaByDrugsYearNoPage(page);
			String title = "按年度统计药品采购情况";
			String[] headers = {"年度","通用名","剂型","规格","转换系数","包装单位", "生产企业","药品分类","采购总金额(万)", "配送金额(万)","配送率","入库金额(万)","入库率"};
			String[] alias = {"date","drug_name","form_name","spec_name","factor","unit_name","prod_compname","drug_cat","total_amount","del_amount","del_ratio","recp_amount","recp_ratio"};
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	
	
	
	//******************************采购总量导出*********************************
	/**
	 * 
	 *@category 采购总量月度导出excel
	 *@author lil
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithAllMon")
	@ResponseBody
	public Pagination exportExcelWithAllMon(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			String starttime = request.getParameter("starttime");
			if (StringUtils.isNotBlank(starttime)){
				starttime = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(starttime)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(starttime));
				page.getConditions().put("starttime", starttime);
			}
			String endtime = request.getParameter("endtime");
			if (StringUtils.isNotBlank(endtime)){
				endtime = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endtime)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endtime));
				page.getConditions().put("endtime", endtime);
			}
			
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			
			page.getConditions().put("NoPage", "1");
			getAreaIdWithWSJ(page);
			String title = ExcelUtil.processFileName(request, "月度采购汇总列表");  
			response.addHeader("Content-Disposition", "attachment;filename="+title+".xls"); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			String names = page.getConditions().get("colNames");
			String[] headers =names.split(",");
			String[] alias =page.getConditions().get("colModel").split(",");
			page.getConditions().remove("colNames");
			page.getConditions().remove("colModel");
			page = anaDruginfoManager.getAnaByAllMonth(page);
			ExcelUtil.exportExcel(page, os, "月度采购汇总列表", headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 采购总量季度导出excel
	 *@author lil
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithAllSea")
	@ResponseBody
	public Pagination exportExcelWithAllSea(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			response.addHeader("Content-Disposition", "attachment;filename="+new String("季度采购汇总列表.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getAnaByAllSeaNoPage(page);
			String title = "季度采购汇总列表";
			String[] headers = {"季度","药品分类","采购金额","配送金额","入库金额","配送率", "入库率" };
			String[] alias = {"date","drug_cat", "total_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 采购总量按年度导出excel
	 *@author lil
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithAllYear")
	@ResponseBody
	public Pagination exportExcelWithAllYear(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			response.addHeader("Content-Disposition", "attachment;filename="+new String("年度采购汇总列表.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getAnaByAllYearNoPage(page);
			String title = "年度采购汇总列表";
			String[] headers = {"年度","药品分类","采购金额","配送金额","入库金额","配送率", "入库率" };
			String[] alias = {"date","drug_cat", "total_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	
	//end
	/**
	 * 
	 *@category 医院按月度导出excel
	 *@author 应晓川
	 *@date 2015年12月23日13:07:30
	 *Pagination
	 */
	@RequestMapping("exportExcelHospWithMon")
	@ResponseBody
	public Pagination exportExcelHospWithMon(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			String title = ExcelUtil.processFileName(request, "按月度统计医院采购情况");  
			response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			String[] headers =page.getConditions().get("colNames").split(",");
			String[] alias =page.getConditions().get("colModel").split(",");
			page = anaDruginfoManager.getMonthAnaByHosp(page);
			ExcelUtil.exportExcel(page, os, "按月度统计医院采购情况", headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 医院按季度导出excel
	 *@author 应晓川
	 *@date 2015年12月23日13:07:30
	 *Pagination
	 */
	@RequestMapping("exportExcelHospWithSea")
	@ResponseBody
	public Pagination exportExcelHospWithSea(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			response.addHeader("Content-Disposition", "attachment;filename="+new String("按季度统计医院采购情况.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			String title = "按季度统计医院采购情况";
			String names = new String(page.getConditions().get("colNames").getBytes("iso8859-1"),"utf-8");
			String[] headers =names.split(",");
			String[] alias =page.getConditions().get("colModel").split(",");
			page.getConditions().remove("colNames");
			page.getConditions().remove("colModel");
			page = anaDruginfoManager.getSeaAnaByHospNoPage(page);
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 医院按年度导出excel
	 *@author 应晓川
	 *@date 2015年12月23日13:07:30
	 *Pagination
	 */
	@RequestMapping("exportExcelHospWithYear")
	@ResponseBody
	public Pagination exportExcelHospWithYear(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		DbUtil.jsonToMap(request, page);
		try {
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
			response.addHeader("Content-Disposition", "attachment;filename="+new String("按年度统计医院采购情况.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			String title = "按年度统计医院采购情况";
			String names = new String(page.getConditions().get("colNames").getBytes("iso8859-1"),"utf-8");
			String[] headers =names.split(",");
			String[] alias =page.getConditions().get("colModel").split(",");
			page.getConditions().remove("colNames");
			page.getConditions().remove("colModel");
			page = anaDruginfoManager.getYearAnaByHospNoPage(page);
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	
	//******************************配送情况导出*********************************
	/**
	 * 
	 *@category 配送情况月度导出excel
	 *@author lil
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithCompMon")
	@ResponseBody
	public Pagination exportExcelWithCompMon(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if(Constants.HSZX==user.getType()){
			StdHealthbureau shb = user.getInfo();
			String areaId = shb.getArea().getAreaid();
			page.getConditions().put("areaId", areaId);
		}
		DbUtil.jsonToMap(request, page);
		try {
			String title = ExcelUtil.processFileName(request, "配送企业月度统计汇总列表");  
			response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getMonthAnaByCompNoPage(page);
			String[] headers = {"月度","配送企业","采购总金额(万元)","配送金额(万元)", "入库金额(万元)", "配送率", "入库率"};
			String[] alias = {"date","del_comp_name", "total_amount",  "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
			ExcelUtil.exportExcel(page, os, "配送企业月度统计汇总列表", headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 配送情况季度导出excel
	 *@author lil
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithCompSea")
	@ResponseBody
	public Pagination exportExcelWithCompSea(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
		}
		DbUtil.jsonToMap(request, page);
		try {
			response.addHeader("Content-Disposition", "attachment;filename="+new String("配送企业季度统计列表.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getSeaAnaByCompNoPage(page);
			String title = "配送企业季度统计列表";
			String[] headers = {"季度","配送企业","采购总金额","西药采购金额","中药采购金额","配送金额", "入库金额", "中药采购率", "配送率", "入库率", "退货率" };
			String[] alias = {"date","del_comp_name", "total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "eastern_ratio", "del_ratio", "recp_ratio", "ret_ratio"};
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
	/**
	 * 
	 *@category 配送情况按年度导出excel
	 *@author lil
	 *@date 2015年12月22日14:46:06
	 *Pagination
	 */
	@RequestMapping("exportExcelWithCompYear")
	@ResponseBody
	public Pagination exportExcelWithCompYear(HttpServletResponse response){
		Pagination page = new Pagination(request);
		printParams();
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if (Constants.HSZX == user.getType()) {
			String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
			page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
		}
		DbUtil.jsonToMap(request, page);
		try {
			response.addHeader("Content-Disposition", "attachment;filename="+new String("配送企业年度统计列表.xls".getBytes("utf-8"),"iso8859-1")); 
			OutputStream os= new BufferedOutputStream(response.getOutputStream());  
			response.setContentType("application/vnd.ms-excel;charset=utf-8");  
			page = anaDruginfoManager.getYearAnaByCompNoPage(page);
			String title = "配送企业年度统计列表";
			String[] headers = {"年度","配送企业","采购总金额","西药采购金额","中药采购金额","配送金额", "入库金额", "中药采购率", "配送率", "入库率", "退货率" };
			String[] alias = {"date","del_comp_name", "total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "eastern_ratio", "del_ratio", "recp_ratio", "ret_ratio"};
			ExcelUtil.exportExcel(page, os, title, headers, alias);
			page.setSuccess(true);
		} catch (Exception e) {
			page.setSuccess(false);
			e.printStackTrace();
		}
		return page;
	}
		
	//end
	
	//******************************地区采购情况导出*********************************
		/**
		 * 
		 *@category 地区采购月度导出excel
		 *@author lil
		 *@date 2015年12月22日14:46:06
		 *Pagination
		 */
		@RequestMapping("exportExcelWithAreaMon")
		@ResponseBody
		public Pagination exportExcelWithAreaMon(HttpServletResponse response){
			Pagination page = new Pagination(request);
			DbUtil.jsonToMap(request, page);
			
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			String title = "地区月度统计汇总列表";
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}else {
				String area1 = request.getParameter("area1");
				if (StringUtils.isNotBlank(area1)){
					page.getConditions().put("area1", area1);
				}
				String area2 = request.getParameter("area2");
				if (StringUtils.isNotBlank(area2)){
					page.getConditions().put("area2", area2);
				}
				String area3 = request.getParameter("area3");
				if (StringUtils.isNotBlank(area3)){
					page.getConditions().put("area3", area3);
				}
			}
			
			String startMon = request.getParameter("startMon");
			if (StringUtils.isNotBlank(startMon)){
				startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
				page.getConditions().put("startMon", startMon);
			}
			
			String endMon = request.getParameter("endMon");
			if (StringUtils.isNotBlank(endMon)){
				endMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endMon));
				page.getConditions().put("endMon", endMon);
			}
			
			try {
				String titleTrue = title;
				page.getConditions().put("NoPage", "1");
				getAreaIdWithWSJ(page);
				title = ExcelUtil.processFileName(request, title);  
				response.addHeader("Content-Disposition", "attachment;filename="+title+".xls"); 
				OutputStream os= new BufferedOutputStream(response.getOutputStream());  
				response.setContentType("application/vnd.ms-excel;charset=utf-8");  
				String names = page.getConditions().get("colNames");
				String[] headers =names.split(",");
				String[] alias =page.getConditions().get("colModel").split(",");
				page.getConditions().remove("colNames");
				page.getConditions().remove("colModel");
				page = anaDruginfoManager.getAnaByAreaWithMon(page);
				ExcelUtil.exportExcel(page, os, titleTrue, headers, alias);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
		/**
		 * 
		 *@category 地区采购季度导出excel
		 *@author lil
		 *@date 2015年12月22日14:46:06
		 *Pagination
		 */
		@RequestMapping("exportExcelWithAreaSea")
		@ResponseBody
		public Pagination exportExcelWithAreaSea(HttpServletResponse response){
			Pagination page = new Pagination(request);
			String title = "地区季度统计列表";
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
				title = "总体采购季度统计";
			}else {
				String area1 = request.getParameter("area1");
				if (StringUtils.isNotBlank(area1)){
					page.getConditions().put("area1", area1);
				}
				String area2 = request.getParameter("area2");
				if (StringUtils.isNotBlank(area2)){
					page.getConditions().put("area2", area2);
				}
				String area3 = request.getParameter("area3");
				if (StringUtils.isNotBlank(area3)){
					page.getConditions().put("area3", area3);
				}
			}
			
			
			String startSea = request.getParameter("startSea");
			if (StringUtils.isNotBlank(startSea)){
				startSea = startSea.replace("年", "0");
				startSea = startSea.replace("季度", "");
				page.getConditions().put("startSea", startSea);
			}
			
			String endSea = request.getParameter("endSea");
			if (StringUtils.isNotBlank(endSea)){
				endSea = endSea.replace("年", "0");
				endSea = endSea.replace("季度", "");
				page.getConditions().put("endSea", endSea);
			}
			
			try {
				response.addHeader("Content-Disposition", "attachment;filename="+new String((title+".xls").getBytes("utf-8"),"iso8859-1")); 
				OutputStream os= new BufferedOutputStream(response.getOutputStream());  
				response.setContentType("application/vnd.ms-excel;charset=utf-8");  
				page = anaDruginfoManager.getAnaByAreaWithSeaNoPage(page);
				
				String[] headers = {"季度","地区","采购总金额","西药采购金额","中药采购金额","配送金额", "入库金额", "中药采购率", "配送率", "入库率", "退货率" };
				String[] alias = {"date","area_name", "total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "eastern_ratio", "del_ratio", "recp_ratio", "ret_ratio"};
				ExcelUtil.exportExcel(page, os, title, headers, alias);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
		/**
		 * 
		 *@category 地区采购情况按年度导出excel
		 *@author lil
		 *@date 2015年12月22日14:46:06
		 *Pagination
		 */
		@RequestMapping("exportExcelWithAreaYear")
		@ResponseBody
		public Pagination exportExcelWithAreaYear(HttpServletResponse response){
			Pagination page = new Pagination(request);
			String tiName = "";
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
				tiName = "总体采购年度统计";
			}else {
				String area1 = request.getParameter("area1");
				if (StringUtils.isNotBlank(area1)){
					page.getConditions().put("area1", area1);
				}
				String area2 = request.getParameter("area2");
				if (StringUtils.isNotBlank(area2)){
					page.getConditions().put("area2", area2);
				}
				String area3 = request.getParameter("area3");
				if (StringUtils.isNotBlank(area3)){
					page.getConditions().put("area3", area3);
				}
				tiName = "地区年度统计列表";
			}
			String startYear = request.getParameter("startYear");
			String endYear = request.getParameter("endYear");
			if (StringUtils.isNotBlank(startYear)){
				page.getConditions().put("startYear", startYear);
			}
			if (StringUtils.isNotBlank(endYear)){
				page.getConditions().put("endYear", endYear);
			}
			try {
				response.addHeader("Content-Disposition", "attachment;filename="+new String((tiName+".xls").getBytes("utf-8"),"iso8859-1")); 
				OutputStream os= new BufferedOutputStream(response.getOutputStream());  
				response.setContentType("application/vnd.ms-excel;charset=utf-8");  
				page = anaDruginfoManager.getAnaByAreaWithYearNoPage(page);
				String title = tiName;
				String[] headers = {"年度","地区","采购总金额","西药采购金额","中药采购金额","配送金额", "入库金额", "中药采购率", "配送率", "入库率", "退货率" };
				String[] alias = {"date","area_name", "total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "eastern_ratio", "del_ratio", "recp_ratio", "ret_ratio"};
				ExcelUtil.exportExcel(page, os, title, headers, alias);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
			
		//end
		/**
		 * 
		 *@category 如果是当前角色是卫生局则获取其地区id
		 *@date 2015年12月24日09:43:51
		 *@param 
		 *@return String
		 */
		private void getAreaIdWithWSJ (Pagination page){
			SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if (Constants.HSZX == user.getType()) {
				String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
				page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
			}
		}
		
		/**
		 * @category 地区采购情况跳转
		 * @date 2015年12月1日10:55:55
		 * @author lil
		 * @return
		 * @throws UnsupportedEncodingException 
		 */
		@RequestMapping("/toAnaByAreaTzs")
		public String toAnaByAreaTzs(String hospCode) throws UnsupportedEncodingException {
			String type = request.getParameter("type");
			request.setAttribute("dateType", request.getParameter("dateType"));
			request.setAttribute("date", request.getParameter("date"));
			String hospName = new String(request.getParameter("hospName").getBytes("ISO8859-1"),"utf-8");
			request.setAttribute("hospName",hospName);
			request.setAttribute("hospCode", hospCode);
			request.setAttribute("totalamount", request.getParameter("totalamount"));
			request.setAttribute("delamount", request.getParameter("delamount"));
			request.setAttribute("recpamount", request.getParameter("recpamount"));
			request.setAttribute("type", type);
			String url = "";
			//type 1医疗机构2药品3配送企业4生产企业
			if("2".equals(type)) {
				url = "/pro/base/anaDruginfo/anaByAreaTzDrugs";
			}else if("3".equals(type)) {
				url = "/pro/base/anaDruginfo/anaByAreaTzDels";
			}else if("4".equals(type)) {
				url = "/pro/base/anaDruginfo/anaByAreaTzProds";
			}
			return url;
		}		
		@RequestMapping("getAnaHospTotal")
		@ResponseBody
		public Pagination getAnaHospTotal(){
			Pagination page = new Pagination(request);
			printParams();
			DbUtil.jsonToMap(request, page);
			try {
				page.getConditions().put("Paging", "Paging");
				anaDruginfoManager.getAnaHospdruginfoTotal(page);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
		@RequestMapping("exportExcelAnaHospTotal")
		@ResponseBody
		public Pagination exportExcelAnaHospTotal(HttpServletResponse response){
			Pagination page = new Pagination(request);
			printParams();
			DbUtil.jsonToMap(request, page);
			try {
				getAreaIdWithWSJ(page);
				
				String title = "";
				String type = page.getConditions().get("type");
				if("2".equals(type)) {
					title = "按月度统计药品采购情况";
				}else if("3".equals(type)) {
					title = "按月度统计配送企业采购情况";
				}else if("4".equals(type)) {
					title = "按月度统计生产企业采购情况";
				}
				String titleTrue  =  title;
				title = ExcelUtil.processFileName(request, title);  
				response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
				OutputStream os= new BufferedOutputStream(response.getOutputStream());  
				response.setContentType("application/vnd.ms-excel;charset=utf-8");  
				String[] headers =page.getConditions().get("colNames").split(",");
				String[] alias =page.getConditions().get("colModel").split(",");
				page.getConditions().remove("colNames");
				page.getConditions().remove("colModel");
				page = anaDruginfoManager.getAnaHospdruginfoTotal(page);
				ExcelUtil.exportExcel(page, os, titleTrue, headers, alias);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
		
		/**
		 * 
		 *@category 按月医疗机构采购情况->跳转药品采购情况
		 *@date 2015年12月24日09:43:51
		 *@param 
		 *@return String
		 */
		@RequestMapping("/toAnaHospdruginfoTotalMon")
		public String toAnaHospdruginfoTotalMon() throws UnsupportedEncodingException {
			printParams();
			request.setAttribute("hospCode", request.getParameter("hospCode") );
			String hospName = new String(request.getParameter("hospName").getBytes("ISO8859-1"),"utf-8");
			request.setAttribute("hospName",hospName);
			request.setAttribute("date",request.getParameter("date"));
			request.setAttribute("totalamount",request.getParameter("totalamount"));
			return "/pro/base/anaDruginfo/anaHospdruginfoTotalMon";
		}
		@RequestMapping("getAnaHospdruginfoTotalMon")
		@ResponseBody
		public Pagination getAnaHospdruginfoTotalMon(){
			printParams();
			Pagination page = new Pagination(request);
			DbUtil.jsonToMap(request, page);
			try {
				//getAreaIdWithWSJ(page);
				page.getConditions().put("Paging", "Paging");
				anaDruginfoManager.getAnaHospdruginfoTotal(page);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
			/**
		 * 
		 *@category 按季医疗机构采购情况->跳转药品采购情况
		 *@date 2015年12月24日18:44:43
		 *@param 
		 *@return String
		 */
		@RequestMapping("/toAnaHospdruginfoTotalSea")
		public String toAnaHospdruginfoTotalSea(String hospCode,String hospName,String date){
			printParams();
			request.setAttribute("hospCode", hospCode );
			request.setAttribute("hospName",hospName);
			request.setAttribute("date",date);
			return "/pro/base/anaDruginfo/anaHospdruginfoTotalSea";
		}
		@RequestMapping("getAnaHospdruginfoTotalSea")
		@ResponseBody
		public Pagination getAnaHospdruginfoTotalSea(){
			printParams();
			Pagination page = new Pagination(request);
			DbUtil.jsonToMap(request, page);
			try {
				getAreaIdWithWSJ(page);
				page.getConditions().put("time", "sea");
				anaDruginfoManager.getAnaHospdruginfoTotal(page);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}
		/**
		 * 
		 *@category 按年医疗机构采购情况->跳转药品采购情况
		 *@date 2015年12月24日09:43:51
		 *@param 
		 *@return String
		 */
		@RequestMapping("/toAnaHospdruginfoTotalYear")
		public String toAnaHospdruginfoTotalYear(String hospCode,String hospName,String date){
			printParams();
			request.setAttribute("hospCode", hospCode );
			request.setAttribute("hospName",hospName);
			request.setAttribute("date",date);
			return "/pro/base/anaDruginfo/anaHospdruginfoTotalYear";
		}
		@RequestMapping("getAnaHospdruginfoTotalYear")
		@ResponseBody
		public Pagination getAnaHospdruginfoTotalYear(){
			printParams();
			Pagination page = new Pagination(request);
			DbUtil.jsonToMap(request, page);
			try {
				getAreaIdWithWSJ(page);
				page.getConditions().put("time", "year");
				anaDruginfoManager.getAnaHospdruginfoTotal(page);
				page.setSuccess(true);
			} catch (Exception e) {
				page.setSuccess(false);
				e.printStackTrace();
			}
			return page;
		}

		
		//******************************配送企业相关药品统计查询***********************************
			
			
			/**
			 * 
			 *@category 配送企业相关药品统计（月）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByDrugWithMon")
			@ResponseBody
			public Pagination getAnaDelByDrugWithMon(){
				Pagination page = new Pagination(request);
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("areaId", areaId);
				}
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("drugCat", request.getParameter("drugCat"));
				page.getConditions().put("drugName", request.getParameter("drugName"));
				return anaDruginfoManager.getAnaDelByDrug(page, "1");
			}
			
			/**
			 * 
			 *@category 配送企业相关药品统计（季）
			 *@author lil
			 *@date 2015年12月3日 上午10:01:14
			 *@param 
			 *@return String
			 */
			@RequestMapping("/toAnaDelByDrugWithSea")
			public String toAnaDelByDrugWithSea(String compCode){
				request.setAttribute("compCode", compCode);
				return "/pro/base/anaDruginfo/anaDelByDrugWithSea";
			}
			/**
			 * 
			 *@category 配送企业相关药品统计（季）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByDrugWithSea")
			@ResponseBody
			public Pagination getAnaDelByDrugWithSea(String compCode){
				Pagination page = new Pagination(request);
				String startSea = request.getParameter("startSea");
				if (StringUtils.isNotBlank(startSea)){
					startSea = startSea.replace("年", "0");
					startSea = startSea.replace("季度", "");
				}
				page.getConditions().put("startDate", startSea);
				String endSea = request.getParameter("endSea");
				if (StringUtils.isNotBlank(endSea)){
					endSea = endSea.replace("年", "0");
					endSea = endSea.replace("季度", "");
				}
				page.getConditions().put("endDate", endSea);
				if(!StringUtils.isNotBlank(compCode)) {
					compCode = request.getParameter("compCode");
					page.getConditions().put("compCode", compCode);
				}else {
					page.getConditions().put("compCode", compCode);
				}
				page.getConditions().put("drugCat", request.getParameter("drugCat"));
				return anaDruginfoManager.getAnaDelByDrug(page, "2");
			}
			
			/**
			 * 
			 *@category 配送企业相关药品统计（年）
			 *@author lil
			 *@date 2015年12月3日 上午10:01:14
			 *@param 
			 *@return String
			 */
			@RequestMapping("/toAnaDelByDrugWithYear")
			public String toAnaDelByDrugWithYear(String compCode){
				request.setAttribute("compCode", compCode);
				return "/pro/base/anaDruginfo/anaDelByDrugWithYear";
			}
			/**
			 * 
			 *@category 配送企业相关药品统计（年）
			 *@author 邱磊
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByDrugWithYear")
			@ResponseBody
			public Pagination getAnaDelByDrugWithYear(String compCode){
				Pagination page = new Pagination(request);
				page.getConditions().put("startDate", request.getParameter("startYear"));
				page.getConditions().put("endDate", request.getParameter("endYear"));
				if(!StringUtils.isNotBlank(compCode)) {
					compCode = request.getParameter("compCode");
					page.getConditions().put("compCode", compCode);
				}else {
					page.getConditions().put("compCode", compCode);
				}
				page.getConditions().put("drugCat", request.getParameter("drugCat"));
				return anaDruginfoManager.getAnaDelByDrug(page, "3");
			}
			
		//******************************end**************************************************
			
			/**
			 * 
			 *@category 药品采购情况->跳转医疗机构采购情况
			 *@date 2015年12月24日09:43:51
			 *@param 
			 *@return String
			 */
			@RequestMapping("/toAnaHospdruginfoTotal")
			public String toAnaHospdruginfoTotal(String totalAmount,String drugCode,String drugName,String date,String time ){
				printParams();
				request.setAttribute("totalAmount", totalAmount );
				request.setAttribute("drugCode", drugCode );
				request.setAttribute("drugName",drugName);
				request.setAttribute("date",date);
				request.setAttribute("time",time);
				String timeName = time.equals("mon")?"月度":(time.equals("sea")?"季度":(time.equals("year")?"年度":""));
				request.setAttribute("timeName",timeName);
				request.setAttribute("province", sysProvince);
				Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
				request.setAttribute("provinceName", area.get("area_name"));
				
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if (Constants.HSZX == user.getType()) {
					String areaId =  hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
					request.setAttribute("province2", areaId);
					area = dicAreaManager.getAreaByAreaId(areaId); 
					request.setAttribute("provinceName2", area.get("area_name"));
				}
				
				List<SelectForm> list = selectManager.getDiSys("002");
				request.setAttribute("list", list);
				request.setAttribute("delAmount", request.getParameter("delAmount"));
				request.setAttribute("recpAmount", request.getParameter("recpAmount"));
				return "/pro/base/anaDruginfo/anaHospdruginfoTotal";
			}
			@RequestMapping("getAnaHospdruginfoTotal")
			@ResponseBody
			public Pagination getAnaHospdruginfoTotal(){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					page.getConditions().put("Paging", "Paging");
					getAreaIdWithWSJ(page);
					anaDruginfoManager.getAnaHospdruginfoTotalByDrug(page);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转地区采购情况
			 *@date 2015年12月24日09:43:51
			 *@param 
			 *@return String
			 */
			@RequestMapping("/toAnaAreadruginfoTotal")
			public String toAnaAreadruginfoTotal(String totalAmount,String drugCode,String drugName,String date,String time){
				printParams();
				request.setAttribute("totalAmount", totalAmount );
				request.setAttribute("drugCode", drugCode );
				request.setAttribute("drugName",drugName);
				request.setAttribute("date",date);
				request.setAttribute("time",time);
				String timeName = time.equals("mon")?"月度":(time.equals("sea")?"季度":(time.equals("year")?"年度":""));
				request.setAttribute("timeName",timeName);
				request.setAttribute("sysProvince",sysProvince);
				Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
				request.setAttribute("sysProvname",area.get("area_name"));
				request.setAttribute("delAmount", request.getParameter("delAmount"));
				request.setAttribute("recpAmount", request.getParameter("recpAmount"));
				return "/pro/base/anaDruginfo/anaAreadruginfoTotal";
			}
			@RequestMapping("getAnaAreadruginfoTotal")
			@ResponseBody
			public Pagination getAnaAreadruginfoTotal(){
				printParams();
				Pagination page = new Pagination(request);
				DbUtil.jsonToMap(request, page);
				try {
					//getAreaIdWithWSJ(page);
					page.getConditions().put("Paging", "Paging");
				    String areaIdBySearch = page.getConditions().get("area3");
		            if( areaIdBySearch == null || areaIdBySearch == "" ){
		            	areaIdBySearch =  page.getConditions().get("area2");
		            }
		            if( areaIdBySearch == null || areaIdBySearch == "" ){
		            	areaIdBySearch =  page.getConditions().get("area1");
		            }
		            if(StringUtils.isNotBlank(areaIdBySearch)){
		            	page.getConditions().put("areaIdBySearch", AreaUtil.escapeAreaId(areaIdBySearch).replace("_", "")+"%");
		            }
					anaDruginfoManager.getAnaAreadruginfoTotal(page);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转配送企业采购情况
			 *@date 2015年12月24日09:43:51
			 *@param 
			 *@return String
			 */
			@RequestMapping("/toAnaDeldruginfoTotal")
			public String toAnaDeldruginfoTotal(String totalAmount,String drugCode,String drugName,String date,String time){
				printParams();
				request.setAttribute("totalAmount", totalAmount );
				request.setAttribute("drugCode", drugCode );
				request.setAttribute("drugName",drugName);
				request.setAttribute("date",date);
				request.setAttribute("time",time);
				String timeName = time.equals("mon")?"月度":(time.equals("sea")?"季度":(time.equals("year")?"年度":""));
				request.setAttribute("timeName",timeName);
				request.setAttribute("delAmount", request.getParameter("delAmount"));
				request.setAttribute("recpAmount", request.getParameter("recpAmount"));
				return "/pro/base/anaDruginfo/anaDeldruginfoTotal";
			}
			@RequestMapping("getAnaDeldruginfoTotal")
			@ResponseBody
			public Pagination getAnaDeldruginfoTotal(){
				printParams();
				Pagination page = new Pagination(request);
				DbUtil.jsonToMap(request, page);
				try {
					page.getConditions().put("Paging", "Paging");
					//getAreaIdWithWSJ(page);
					anaDruginfoManager.getAnaDeldruginfoTotal(page);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转生产企业采购情况
			 *@date 2015年12月27日16:33:52
			 *@param 
			 *@return String
			 */
			@RequestMapping("/toAnaProddruginfoTotal")
			public String toAnaProddruginfoTotal(String totalAmount,String drugCode,String drugName,String date,String time){
				printParams();
				request.setAttribute("totalAmount", totalAmount );
				request.setAttribute("drugCode", drugCode );
				request.setAttribute("drugName",drugName);
				request.setAttribute("date",date);
				request.setAttribute("time",time);
				String timeName = time.equals("mon")?"月度":(time.equals("sea")?"季度":(time.equals("year")?"年度":""));
				request.setAttribute("timeName",timeName);
				return "/pro/base/anaDruginfo/anaProddruginfoTotal";
			}
			@RequestMapping("getAnaProddruginfoTotal")
			@ResponseBody
			public Pagination getAnaProddruginfoTotal(){
				printParams();
				Pagination page = new Pagination(request);
				DbUtil.jsonToMap(request, page);
				try {
					page.getConditions().put("Paging", "Paging");
				//	getAreaIdWithWSJ(page);
					anaDruginfoManager.getAnaProddruginfoTotal(page);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
	
			
	//***********************************配送企业地区统计信息**************************************
			
			
			/**
			 * @category 地区采购情况跳转
			 * @date 2015年12月1日10:55:55
			 * @author lil
			 * @return
			 */
			@RequestMapping("/toAnaByAreaTz")
			public String toAnaByAreaTz() {
				String type = request.getParameter("type");
				
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if (Constants.HSZX != user.getType()) {
					
					request.setAttribute("areaId", request.getParameter("areaId"));
					try {
						request.setAttribute("areaName", URLDecoder.decode(request.getParameter("areaName"),"UTF-8"));
					} catch (UnsupportedEncodingException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					request.setAttribute("mbxbt", "地区采购情况");
				}else {
					request.setAttribute("mbxbt", "总体采购情况");
				}
				List<SelectForm> list = selectManager.getDiSys("002");
				request.setAttribute("list", list);
				request.setAttribute("dateType", request.getParameter("dateType"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("delA", request.getParameter("delA"));
				request.setAttribute("recpA", request.getParameter("recpA"));
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("type", type);
				String url = "";
				//type 1医疗机构2药品3配送企业4生产企业
				if("1".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAreaTzHosp";
				}else if("2".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAreaTzDrug";
				}else if("3".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAreaTzDel";
				}else if("4".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAreaTzProd";
				}
				return url;
			}
			
			
			/**
			 * @category 地区采购情况跳转
			 * @date 2015年12月1日10:55:55
			 * @author lil
			 * @return
			 */
			@ResponseBody
			@RequestMapping("/getAnaByAreaTz")
			public Pagination getAnaByAreaTz(String areaId) {
				Pagination page = new Pagination(request);
				String hospClassifys = request.getParameter("hospClassifys");
				page.getConditions().put("hospClassifys", hospClassifys);
				String hospType = request.getParameter("hospType");
				page.getConditions().put("hospType", hospType);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						page.getConditions().put("areaId", hospCatalogManager.getAreaIdByOrgId(user.getOrgId()));
					}
					DbUtil.jsonToMap(request, page);
					page = anaDruginfoManager.getAnaByAreaTz(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}	
			
	//***********************************end***************************************************
			
			
	//***********************************生产企业采购情况******************************************
			/**
			 * @category 生产企业采购情况(月)
			 * @date 2015年12月1日10:55:55
			 * @author lil
			 * @return
			 */
			@RequestMapping("/toAnaByProdcompMon")
			public String toAnaByProdcompMon() {
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if (Constants.HSZX == user.getType()) {
					String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
					request.setAttribute("areaId", areaId);
				}
				request.setAttribute("lastMonth", ParseDate.addMonth(new Date(), -1));
				return "/pro/base/anaDruginfo/anaByProdcompMon";
			}
			
			/**
			 * @category 生产企业采购情况(月)
			 * @date 2015年12月1日10:55:55
			 * @author lil
			 * @return
			 */
			@ResponseBody
			@RequestMapping("/getAnaByProdcompMon")
			public Pagination getAnaByProdcompMon(String date) {
				Pagination page = new Pagination(request);
				try {
					DbUtil.jsonToMap(request, page);
					String startDate = request.getParameter("startDate");
					if (StringUtils.isNotBlank(startDate)){
						startDate = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startDate)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startDate));
						page.getConditions().put("startDate", startDate);
					}
					String endDate = request.getParameter("endDate");
					if (StringUtils.isNotBlank(endDate)){
						endDate = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endDate)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endDate));
						page.getConditions().put("endDate", endDate);
					}
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					page = anaDruginfoManager.getAnaByProdcomp(page, "1");
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			/**
			 * 
			 *@category 获取生产企业采购情况排名数据（月）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaByProdcompChartWithMon")
			@ResponseBody
			public Pagination getAnaByProdcompChartWithMon(String date){
				Pagination page = new Pagination(request);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					String startMon = request.getParameter("startMon");
					if (StringUtils.isNotBlank(startMon)){
						startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
					}
					page.getConditions().put("startMon", startMon);
					page = anaDruginfoManager.getAnaByProdcompChartWithMon(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			
			
			/**
			 * @category 生产企业采购情况跳转
			 * @date 2015年12月1日10:18:44
			 * @return
			 */
			@RequestMapping("/toAnaByProdcompTz")
			public String toAnaByProdcompTz() {
				String type = request.getParameter("type");
				request.setAttribute("dateType", request.getParameter("dateType"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("delA", request.getParameter("delA"));
				request.setAttribute("recpA", request.getParameter("recpA"));
				request.setAttribute("prodCode", request.getParameter("prodCode"));
				try {
					request.setAttribute("prodName", URLDecoder.decode(request.getParameter("prodName"),"UTF-8"));
				} catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				request.setAttribute("type", type);
				String url = "";
				//type 1医疗机构2药品3配送企业4地区
				if("1".equals(type)) {
					request.setAttribute("province", sysProvince);
					Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
					request.setAttribute("provinceName", area.get("area_name"));
					
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						request.setAttribute("province2", areaId);
						area = dicAreaManager.getAreaByAreaId(areaId); 
						request.setAttribute("provinceName2", area.get("area_name"));
					}
					List<SelectForm> list = selectManager.getDiSys("002");
					request.setAttribute("list", list);
					
					url = "/pro/base/anaDruginfo/anaByProdcompTzHosp";
				}else if("2".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByProdcompTzDrug";
				}else if("3".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByProdcompTzDel";
				}else if("4".equals(type)) {
					request.setAttribute("province", sysProvince);
					Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
					request.setAttribute("provinceName", area.get("area_name"));
					
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						request.setAttribute("province2", areaId);
						area = dicAreaManager.getAreaByAreaId(areaId); 
						request.setAttribute("provinceName2", area.get("area_name"));
					}
					url = "/pro/base/anaDruginfo/anaByProdcompTzArea";
				}
				return url;
			}
			
			
			
			/**
			 * @category 生产企业采购情况跳转
			 * @date 2015-12-04
			 * @author lil
			 * @return Pagination
			 */
			@ResponseBody
			@RequestMapping("/getAnaByProdcompTz")
			public Pagination getAnaByProdcompTz() {
				Pagination page = new Pagination(request);
				try {
					DbUtil.jsonToMap(request, page);
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					page = anaDruginfoManager.getAnaByProdcompTz(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			
			
			
			
			/**
			 * @category 生产企业采购情况(季度)
			 * @date 2015年12月1日10:55:55
			 * @return
			 */
			@RequestMapping("/toAnaByProdcompSea")
			public String toAnaByProdcompSea(String date) {
				Calendar calendar = new GregorianCalendar(); 
		        calendar.setTime(ParseDate.addMonth(new Date(), -3));
		        int month = calendar.get(Calendar.MONTH) + 1;
		        String sea = "";
		        if(month == 1 || month ==2 || month ==3){
		       	 sea = calendar.get(Calendar.YEAR)+"年第01季度";
		        }
		        else if(month == 4 || month ==5 || month ==6){
		       	 sea = calendar.get(Calendar.YEAR)+"年第02季度";
		        }
		        else if(month == 7 || month ==8 || month ==9){
		       	 sea = calendar.get(Calendar.YEAR)+"年第03季度";
		        }
		        else if(month == 10 || month ==11 || month ==12){
		       	 sea = calendar.get(Calendar.YEAR)+"年第04季度";
		        }
				
				request.setAttribute("lastSea",sea);
				request.setAttribute("date", date);
				return "/pro/base/anaDruginfo/anaByProdcompSea";
			}
			
			/**
			 * @category 生产企业采购情况(季度)
			 * @date 2015年12月1日10:55:55
			 * @return
			 */
			@ResponseBody
			@RequestMapping("/getAnaByProdcompSea")
			public Pagination getAnaByProdcompSea(String date) {
				Pagination page = new Pagination(request);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					
					String startSea = request.getParameter("startSea");
					if (StringUtils.isNotBlank(startSea)){
						startSea = startSea.replace("年", "0");
						startSea = startSea.replace("季度", "");
						page.getConditions().put("startDate", startSea);
					}
					String endSea = request.getParameter("endSea");
					if (StringUtils.isNotBlank(endSea)){
						endSea = endSea.replace("年", "0");
						endSea = endSea.replace("季度", "");
						page.getConditions().put("endDate", endSea);
					}
					if(!StringUtils.isNotBlank(startSea) && !StringUtils.isNotBlank(endSea)) {//判断是否选择时间
						page.getConditions().put("startDate", date);
						page.getConditions().put("endDate", date);
					}
					DbUtil.jsonToMap(request, page);
					page = anaDruginfoManager.getAnaByProdcomp(page, "2");
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			/**
			 * @category 生产企业采购情况(年)
			 * @date 2015年12月1日10:55:55
			 * @return
			 */
			@RequestMapping("/toAnaByProdcompYear")
			public String toAnaByProdcompYear(String date) {
				request.setAttribute("lastYear", ParseDate.addYear(new Date(), -1));
				request.setAttribute("date", date);
				return "/pro/base/anaDruginfo/anaByProdcompYear";
			}
			
			/**
			 * @category 生产企业采购情况(年)
			 * @date 2015年12月1日10:55:55
			 * @return
			 */
			@ResponseBody
			@RequestMapping("/getAnaByProdcompYear")
			public Pagination getAnaByProdcompYear(String date) {
				Pagination page = new Pagination(request);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					page.getConditions().put("startDate", request.getParameter("startYear"));
					page.getConditions().put("endDate", request.getParameter("endYear"));
					if(!StringUtils.isNotBlank(request.getParameter("startYear")) && !StringUtils.isNotBlank(request.getParameter("endYear"))) {//判断是否选择时间
						page.getConditions().put("startDate", date);
						page.getConditions().put("endDate", date);
					}
					DbUtil.jsonToMap(request, page);
					page = anaDruginfoManager.getAnaByProdcomp(page, "3");
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}	
	//***********************************end*******************************************
			
			
			/**
			 * @category 总体采购情况跳转
			 * @date 2015年12月1日10:18:44
			 * @return
			 */
			@RequestMapping("/toAnaByAllTz")
			public String toAnaByAllTz() {
				String type = request.getParameter("type");
				request.setAttribute("clList", dicSysManager.getDicSysByClassifyCode(Constants.HOSP_CAT));
				request.setAttribute("sysAreaId", sysProvince);
				
				request.setAttribute("province", sysProvince);
				Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
				request.setAttribute("provinceName", area.get("area_name"));
				List<SelectForm> list = selectManager.getDiSys("002");
				request.setAttribute("list", list);
				request.setAttribute("dateType", request.getParameter("dateType"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("del", request.getParameter("del"));
				request.setAttribute("recp", request.getParameter("recp"));
				request.setAttribute("type", type);
				String url = "";
				//type 1医疗机构2药品3配送企业4生产企业
				if("1".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAllTzHosp";
				}else if("2".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAllTzDrug";
				}else if("3".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAllTzDel";
				}else if("4".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAllTzProd";
				}else if("5".equals(type)) {
					url = "/pro/base/anaDruginfo/anaByAllTzArea";
				}
				return url;
			}
			
			/**
			 * @category 总体采购情况跳转
			 * @date 2015-12-04
			 * @author lil
			 * @return Pagination
			 */
			@ResponseBody
			@RequestMapping("/getAnaByAllTz")
			public Pagination getAnaByAllTz() {
				Pagination page = new Pagination(request);
			String shospCl = request.getParameter("shospCl");
			page.getConditions().put("shospCl", shospCl);
				String hospClassifys = request.getParameter("hospClassifys");
				page.getConditions().put("hospClassifys", hospClassifys);
				String hospType = request.getParameter("hospType");
				page.getConditions().put("hospType", hospType);
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if (Constants.HSZX == user.getType()) {
					String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
					page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
				}
				String area1 = request.getParameter("area1");
				page.getConditions().put("area1", area1);
				String area2 = request.getParameter("area2");
				page.getConditions().put("area2", area2);
				String area3 = request.getParameter("area3");
				page.getConditions().put("area3", area3);
				try {
					
					DbUtil.jsonToMap(request, page);
					page = anaDruginfoManager.getAnaByAllTz(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			/**
			 * 
			 *@category 获取地区采购情况排名数据（月）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaByAreaChartWithMon")
			@ResponseBody
			public Pagination getAnaByAreaChartWithMon(String date){
				Pagination page = new Pagination(request);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					String startMon = request.getParameter("startMon");
					if (StringUtils.isNotBlank(startMon)){
						startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
					}
					page.getConditions().put("startMon", startMon);
					page = anaDruginfoManager.getAnaByAreaChartWithMon(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}

			/**
			 * 
			 *@category 获取医疗机构采购情况排名数据（月）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getMonthAnaByHosps")
			@ResponseBody
			public Pagination getMonthAnaByHosps(String date){
				Pagination page = new Pagination(request);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					String startMon = request.getParameter("startMon");
					if (StringUtils.isNotBlank(startMon)){
						startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
						page.getConditions().put("startMon", startMon);
					}
					page = anaDruginfoManager.getMonthAnaByHosps(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			

			/**
			 * 
			 *@category 获取企业采购情况排名数据（月）
			 *@author wangbing
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getChartMonthAnaByComp")
			@ResponseBody
			public Pagination getChartMonthAnaByComp(String startMon){
				Pagination page = new Pagination(request);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					if (StringUtils.isNotBlank(startMon)){
						startMon = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startMon)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startMon));
					}
					page.getConditions().put("startMon", startMon);
					page = anaDruginfoManager.getChartMonthAnaByComp(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			/**
			 * @category 配送企业统计二级跳转
			 * @date 2015年12月1日10:55:55
			 * @author wangbing
			 * @return
			 */
			@RequestMapping("/toAnaByCompTz")
			public String toAnaByCompTz() {
				String type = request.getParameter("type");
				request.setAttribute("delCompCode", request.getParameter("delCompCode"));
				request.setAttribute("dateType", request.getParameter("dateType"));
				request.setAttribute("date", request.getParameter("date"));
				try {
					request.setAttribute("delCompName", new String(request.getParameter("delCompName").getBytes("iso8859-1"),"utf-8"));
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("del", request.getParameter("del"));
				request.setAttribute("recp", request.getParameter("recp"));
				request.setAttribute("type", type);
				String url = "";
				//type 1医疗机构2药品3地区4生产企业
				if("1".equals(type)) {
				request.setAttribute("province", sysProvince);
				Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
				request.setAttribute("provinceName", area.get("area_name"));
				
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if (Constants.HSZX == user.getType()) {
					String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
					request.setAttribute("province2", areaId);
					area = dicAreaManager.getAreaByAreaId(areaId); 
					request.setAttribute("provinceName2", area.get("area_name"));
				}
				List<SelectForm> list = selectManager.getDiSys("002");
				request.setAttribute("list", list);
					url = "/pro/base/anaDruginfo/anaDelByHospWithMon";
				}else if("2".equals(type)) {
					url = "/pro/base/anaDruginfo/anaDelByDrugWithMon";
				}else if("3".equals(type)) {
					request.setAttribute("province", sysProvince);
					Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince);
					request.setAttribute("provinceName", area.get("area_name"));
					url = "/pro/base/anaDruginfo/anaCompinfoByAreaWithMon";
				}else if("4".equals(type)) {
					url = "/pro/base/anaDruginfo/anaDelByProdCompWithMon";
				}
				return url;
			}
			
			/**
			 * 
			 *@category  type 1医疗机构2药品3地区4生产企业
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportExcelWithAreaMonType2")
			@ResponseBody
			public Pagination exportExcelWithAreaMonType2(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("drugCat", request.getParameter("drugCat"));
				page.getConditions().put("drugName", request.getParameter("drugName"));
				page.getConditions().put("noPage", "noPage");
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("areaId", areaId);
				}
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaDelByDrug(page, "1");
					
					String[] headers = {"通用名","剂型","规格","转换系数","单位","生产企业","药品分类","采购总金额(万元)","配送金额(万元)", "入库金额(万元)",  "配送率", "入库率" };
					String[] alias = {"drug_name","form_name","spec_name","factor","unit_name","prod_compname","drug_cat","total_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, "统计汇总", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			
			/**
			 * @category 根据时间查询药品销售统计汇总图标（月度）
			 * @date 2015-12-04
			 * @author lil
			 * @return Pagination
			 */
			@ResponseBody
			@RequestMapping("/getAnaByDrugsWithMonByMchart")
			public Pagination getAnaByDrugsWithMonByMchart() {
				Pagination page = new Pagination(request);
				try {
					DbUtil.jsonToMap(request, page);
					getAreaIdWithWSJ(page);
					String month = request.getParameter("month").replace("-","");
					if (StringUtils.isNotBlank(month)){
						page.getConditions().put("month", month);
					}
					page = anaDruginfoManager.getAnaByDrugsWithMonByMchart(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转医院采购情况 导出excel
			 *@author 应晓川
			 *@date 2015年12月27日18:26:43
			 *Pagination
			 */
			@RequestMapping("exportExcelHospByDrug")
			@ResponseBody
			public Pagination exportExcelHospByDrug(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					getAreaIdWithWSJ(page);
					String title =   "按月度统计医院采购情况";
					String filename = ExcelUtil.processFileName(request, title);
					response.addHeader("Content-Disposition", "attachment;filename="+filename+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String[] headers =page.getConditions().get("colNames").split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaHospdruginfoTotalByDrug(page);
					ExcelUtil.exportExcel(page, os,  "按月度统计医院采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转地区采购情况 导出excel
			 *@author 应晓川
			 *@date 2015年12月28日10:48:15
			 *Pagination
			 */
			@RequestMapping("exportExcelAreaByDrug")
			@ResponseBody
			public Pagination exportExcelAreaByDrug(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					//getAreaIdWithWSJ(page);
				    String areaIdBySearch = page.getConditions().get("area3");
		            if( areaIdBySearch == null || areaIdBySearch == "" ){
		            	areaIdBySearch =  page.getConditions().get("area2");
		            }
		            if( areaIdBySearch == null || areaIdBySearch == "" ){
		            	areaIdBySearch =  page.getConditions().get("area1");
		            }
		            if(StringUtils.isNotBlank(areaIdBySearch)){
		            	page.getConditions().put("areaIdBySearch", AreaUtil.escapeAreaId(areaIdBySearch).replace("_", "")+"%");
		            }
		            String title = ExcelUtil.processFileName(request, "按月度统计地区采购情况");  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String[] headers =page.getConditions().get("colNames").split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaAreadruginfoTotal(page);
					ExcelUtil.exportExcel(page, os, "按月度统计地区采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转配送企业采购情况 导出excel
			 *@author 应晓川
			 *@date 2015年12月28日10:46:45
			 *Pagination
			 */
			@RequestMapping("exportExcelDelByDrug")
			@ResponseBody
			public Pagination exportExcelDelByDrug(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					getAreaIdWithWSJ(page);
					String title = ExcelUtil.processFileName(request, "按月度统计配送企业采购情况");  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String[] headers =page.getConditions().get("colNames").split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaDeldruginfoTotal(page);
					ExcelUtil.exportExcel(page, os, "按月度统计配送企业采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			/**
			 * 
			 *@category 药品采购情况->跳转生产企业采购情况 导出excel
			 *@author 应晓川
			 *@date 2015年12月28日10:52:02
			 *Pagination
			 */
			@RequestMapping("exportExcelProdByDrug")
			@ResponseBody
			public Pagination exportExcelProdByDrug(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					getAreaIdWithWSJ(page);
					String title = ExcelUtil.processFileName(request, "按月度统计生产企业采购情况");  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String[] headers =page.getConditions().get("colNames").split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaProddruginfoTotal(page);
					ExcelUtil.exportExcel(page, os, "按月度统计生产企业采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * 
			 *@category 地区采购情况跳转 导出excel
			 *@author lil
			 *@date 2015年12月27日18:26:43
			 *Pagination
			 */
			@RequestMapping("exportExcelByAreaTz")
			@ResponseBody
			public Pagination exportExcelByAreaTz(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", areaId);
					}
					
					page.getConditions().put("NoPage", "1");
					String title = ExcelUtil.processFileName(request, "按月度统计采购情况");  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String names = page.getConditions().get("colNames");
					String[] headers =names.split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaByAreaTz(page);
					ExcelUtil.exportExcel(page, os, "按月度统计采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}

			
			/**
			 * 
			 *@category 总体采购情况跳转 导出excel
			 *@author lil
			 *@date 2015年12月27日18:26:43
			 *Pagination
			 */
			@RequestMapping("exportExcelByAllTz")
			@ResponseBody
			public Pagination exportExcelByAllTz(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					
					getAreaIdWithWSJ(page);
					page.getConditions().put("NoPage", "1");
					String title = ExcelUtil.processFileName(request, "按月度统计采购情况");  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String names = page.getConditions().get("colNames");
					String[] headers =names.split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaByAllTz(page);
					ExcelUtil.exportExcel(page, os, "按月度统计采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * 
			 *@category  type 1医疗机构2药品3地区4生产企业
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportExcelWithAreaMonType3")
			@ResponseBody
			public Pagination exportExcelWithAreaMonType3(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("area1", request.getParameter("area1"));
				page.getConditions().put("area2", request.getParameter("area2"));
				page.getConditions().put("area3", request.getParameter("area3"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaCompinfoByAreaWithMonExport(page);
					
					String[] headers = {"地区编码","地区名称","采购总金额(万元)","西药采购金额(万元)","中药采购金额(万元)","配送金额(万元)", "入库金额(万元)", "中药采购率", "配送率", "入库率" };
					String[] alias = {"area_id","area_name","total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "eastern_ratio", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, "统计汇总", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * 
			 *@category 配送企业相关医院统计（月）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByHospWithMon")
			@ResponseBody
			public Pagination getAnaDelByHospWithMon(){
				Pagination page = new Pagination(request);
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("hospName", request.getParameter("hospName"));
				page.getConditions().put("area1", sysProvince);
				page.getConditions().put("area2", request.getParameter("area2"));
				page.getConditions().put("area3", request.getParameter("area3"));
				page.getConditions().put("hospClassify", request.getParameter("hospClassify"));
				page.getConditions().put("hospLevelId", request.getParameter("hospLevelId"));
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("orgAreaId", areaId);
				}
				return anaDruginfoManager.getAnaDelByHosp(page);
			}
			
			/**
			 * 
			 *@category  type 1医疗机构2药品3地区4生产企业
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportExcelWithAreaMonType1")
			@ResponseBody
			public Pagination exportExcelWithAreaMonType1(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("hospName", request.getParameter("hospName"));
				page.getConditions().put("area1", sysProvince);
				page.getConditions().put("area2", request.getParameter("area2"));
				page.getConditions().put("area3", request.getParameter("area3"));
				page.getConditions().put("hospClassify", request.getParameter("hospClassify"));
				page.getConditions().put("hospLevelId", request.getParameter("hospLevelId"));
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("orgAreaId", areaId);
				}
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaDelByHospExport(page);
					
					String[] headers = {"医疗机构名称","医疗机构属性","所属地区","医疗机构等级","采购总金额(万元)","西药采购金额(万元)","中药采购金额(万元)","配送金额(万元)", "入库金额(万元)", "配送率", "入库率" };
					String[] alias = {"hosp_name","hosp_classify","hosp_ar_fullname","hosp_level_id","total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, "统计汇总", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * 
			 *@category 配送企业相关生产企业（月）
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByProdCompWithMon")
			@ResponseBody
			public Pagination getAnaDelByProdCompWithMon(){
				Pagination page = new Pagination(request);
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("prodCompName", request.getParameter("prodCompName"));
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("areaId", areaId);
				}
				return anaDruginfoManager.getAnaDelByProdComp(page);
			}
			
			/**
			 * 
			 *@category  type 1医疗机构2药品3地区4生产企业
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportExcelWithAreaMonType4")
			@ResponseBody
			public Pagination exportExcelWithAreaMonType4(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("prodCompName", request.getParameter("prodCompName"));
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("areaId", areaId);
				}
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaDelByProdCompExport(page);
					
					String[] headers = {"生产企业编码","生产企业名称","采购总金额(万元)","西药采购金额(万元)","中药采购金额(万元)","配送金额(万元)", "入库金额(万元)", "中药采购率", "配送率", "入库率" };
					String[] alias = {"prod_comp_code","prod_comp_name","total_amount", "western_amount", "eastern_amount", "del_amount", "recp_amount", "eastern_ratio", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, "统计汇总", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}

			/**
			 * 
			 *@category 生产企业导出数据导出excel
			 *@author lil
			 *@date 2015年12月27日18:26:43
			 *Pagination
			 */
			@RequestMapping("exportExcelByProd")
			@ResponseBody
			public Pagination exportExcelByProd(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					String startDate = page.getConditions().get("startDate");
					if (StringUtils.isNotBlank(startDate)){
						startDate = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(startDate)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(startDate));
						page.getConditions().put("startDate", startDate);
					}
					String endDate = page.getConditions().get("endDate");
					if (StringUtils.isNotBlank(endDate)){
						endDate = ParseDate.parseShortYearFormat(ParseDate.fromYearMonthFormat(endDate)) + ParseDate.parseShortMonthFormat(ParseDate.fromYearMonthFormat(endDate));
						page.getConditions().put("endDate", endDate);
					}
					
					String type = page.getConditions().get("dateType");
					String title = "按月度统计采购情况";
					page.getConditions().put("NoPage", "1");
					getAreaIdWithWSJ(page);
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String names = page.getConditions().get("colNames");
					String[] headers =names.split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaByProdcomp(page, type);
					ExcelUtil.exportExcel(page, os, "按月度统计采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * 
			 *@category 生产企业二级跳转导出数据导出excel
			 *@author lil
			 *@date 2015年12月27日18:26:43
			 *Pagination
			 */
			@RequestMapping("exportExcelByProdTz")
			@ResponseBody
			public Pagination exportExcelByProdTz(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					
					String title = "按月度统计采购情况";
					page.getConditions().put("NoPage", "1");
					getAreaIdWithWSJ(page);
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String names = page.getConditions().get("colNames");
					String[] headers =names.split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaByProdcompTz(page);
					ExcelUtil.exportExcel(page, os, "按月度统计采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			
			
			/**
			 * @category 生产企业采购情况跳转三级
			 * @date 2015年12月1日10:18:44
			 * @return
			 */
			@RequestMapping("/toAnaByProdcompTzThree")
			public String toAnaByProdcompTzThree() {
				String type = request.getParameter("type");
				request.setAttribute("dateType", request.getParameter("dateType"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("delA", request.getParameter("delA"));
				request.setAttribute("recpA", request.getParameter("recpA"));
				request.setAttribute("prodCode", request.getParameter("prodCode"));
				request.setAttribute("type", type);
				String url = "";
				//type 1医疗机构2药品3配送企业
				if("1".equals(type)) {
					request.setAttribute("hospCode", request.getParameter("hospCode"));
					url = "/pro/base/anaDruginfo/anaByProdcompTzDrugThree";
				}else if("2".equals(type)) {
					request.setAttribute("province", sysProvince);
					Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
					request.setAttribute("provinceName", area.get("area_name"));
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						request.setAttribute("province2", areaId);
						area = dicAreaManager.getAreaByAreaId(areaId); 
						request.setAttribute("provinceName2", area.get("area_name"));
					}
					List<SelectForm> list = selectManager.getDiSys("002");
					request.setAttribute("list", list);
					request.setAttribute("drugCode", request.getParameter("drugCode"));
					url = "/pro/base/anaDruginfo/anaByProdcompTzHospThree";
				}else if("3".equals(type)) {
					request.setAttribute("delCode", request.getParameter("delCode"));
					url = "/pro/base/anaDruginfo/anaByProdcompTzDrugThree";
				}
				return url;
			}
			
			
			
			/**
			 * @category 生产企业采购情况跳转三级
			 * @date 2015-12-04
			 * @author lil
			 * @return Pagination
			 */
			@ResponseBody
			@RequestMapping("/getAnaByProdcompTzThree")
			public Pagination getAnaByProdcompTzThree() {
				Pagination page = new Pagination(request);
				try {
					DbUtil.jsonToMap(request, page);
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					page = anaDruginfoManager.getAnaByProdcompTzThree(page);
					page.setSuccess(true);
				} catch (Exception e) {
					log.error("",e);
					page.setSuccess(false);
				}
				return page;
			}
			
			/**
			 * @category 跳 配送企业-药品-医疗机构
			 * @date 2015年12月1日10:55:55
			 * @author wangbing
			 * @return
			 */
			@RequestMapping("/toAnaDelByDrugHospWithMon")
			public String toAnaDelByDrugHospWithMon() {
				request.setAttribute("delCompCode", request.getParameter("delCompCode"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("drugCode", request.getParameter("drugCode"));
				try {
					request.setAttribute("delCompName", new String(request.getParameter("delCompName").getBytes("iso8859-1"),"utf-8"));
					request.setAttribute("drugName", new String(request.getParameter("drugName").getBytes("iso8859-1"),"utf-8"));
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("del", request.getParameter("del"));
				request.setAttribute("recp", request.getParameter("recp"));
				request.setAttribute("province", sysProvince);
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if (Constants.HSZX == user.getType()) {
					String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
					request.setAttribute("province2", areaId);
					Map<String, Object> area = dicAreaManager.getAreaByAreaId(areaId); 
					request.setAttribute("provinceName2", area.get("area_name"));
				}
				request.setAttribute("province", sysProvince);
				Map<String, Object> area = dicAreaManager.getAreaByAreaId(sysProvince); 
				request.setAttribute("provinceName", area.get("area_name"));
				List<SelectForm> list = selectManager.getDiSys("002");
				request.setAttribute("list", list);
				return "/pro/base/anaDruginfo/anaDelByDrugHospWithMon";
			}
			/**
			 * 
			 *@category 获取   配送企业-药品-医疗机构   列表数据
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByDrugHospWithMon")
			@ResponseBody
			public Pagination getAnaDelByDrugHospWithMon(){
				Pagination page = new Pagination(request);
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("drugCode", request.getParameter("drugCode"));
				page.getConditions().put("hospName", request.getParameter("hospName"));
				page.getConditions().put("area1", sysProvince);
				page.getConditions().put("area2", request.getParameter("area2"));
				page.getConditions().put("area3", request.getParameter("area3"));
				page.getConditions().put("hospClassify", request.getParameter("hospClassify"));
				page.getConditions().put("hospLevelId", request.getParameter("hospLevelId"));
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("orgAreaId", areaId);
				}
				return anaDruginfoManager.getAnaDelByDrugHospWithMon(page, "1");
			}
			
			/**
			 * 
			 *@category 生产企业三级跳转导出数据导出excel
			 *@author lil
			 *@date 2015年12月27日18:26:43
			 *Pagination
			 */
			@RequestMapping("exportExcelByProdTzThree")
			@ResponseBody
			public Pagination exportExcelByProdTzThree(HttpServletResponse response){
				Pagination page = new Pagination(request);
				printParams();
				DbUtil.jsonToMap(request, page);
				try {
					SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
					if (Constants.HSZX == user.getType()) {
						String areaId = hospCatalogManager.getAreaIdByOrgId(user.getOrgId());
						page.getConditions().put("areaId", AreaUtil.escapeAreaId(areaId).replace("_", "")+"%");
					}
					
					page.getConditions().put("NoPage", "1");
					getAreaIdWithWSJ(page);
					String title = ExcelUtil.processFileName(request, "按月度统计采购情况");  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls"); 
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					String names = page.getConditions().get("colNames");
					String[] headers =names.split(",");
					String[] alias =page.getConditions().get("colModel").split(",");
					page.getConditions().remove("colNames");
					page.getConditions().remove("colModel");
					page = anaDruginfoManager.getAnaByProdcompTzThree(page);
					ExcelUtil.exportExcel(page, os, "按月度统计采购情况", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * 
			 *@category  
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportAnaDelByDrugHospWithMon")
			@ResponseBody
			public Pagination exportAnaDelByDrugHospWithMon(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("drugCode", request.getParameter("drugCode"));
				page.getConditions().put("hospName", request.getParameter("hospName"));
				page.getConditions().put("area1", sysProvince);
				page.getConditions().put("area2", request.getParameter("area2"));
				page.getConditions().put("area3", request.getParameter("area3"));
				page.getConditions().put("hospClassify", request.getParameter("hospClassify"));
				page.getConditions().put("hospLevelId", request.getParameter("hospLevelId"));
				page.getConditions().put("noPage", "noPage");
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("orgAreaId", areaId);
				}
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaDelByDrugHospWithMon(page, "1");
					
					String[] headers = {"医疗机构名称","医疗机构属性","所属地区","医疗机构等级","采购总金额(万元)","配送金额(万元)", "入库金额(万元)",  "配送率", "入库率" };
					String[] alias = {"hosp_name","hosp_classify","hosp_ar_fullname","hosp_level_id","total_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, "统计汇总", headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * @category 跳 配送企业-医疗机构-药品
			 * @date 2015年12月1日10:55:55
			 * @author wangbing
			 * @return
			 */
			@RequestMapping("/toAnaDelByHospDrugWithMon")
			public String toAnaDelByHospDrugWithMon() {
				request.setAttribute("delCompCode", request.getParameter("delCompCode"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("hospCode", request.getParameter("hospCode"));
				try {
					request.setAttribute("delCompName", new String(request.getParameter("delCompName").getBytes("iso8859-1"),"utf-8"));
					request.setAttribute("hospName", new String(request.getParameter("hospName").getBytes("iso8859-1"),"utf-8"));
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("del", request.getParameter("del"));
				request.setAttribute("recp", request.getParameter("recp"));
				return "/pro/base/anaDruginfo/anaDelByHospDrugWithMon";
			}
			
			
			/**
			 * 
			 *@category 获取   配送企业-医疗机构-药品   列表数据
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByHospDrugWithMon")
			@ResponseBody
			public Pagination getAnaDelByHospDrugWithMon(){
				Pagination page = new Pagination(request);
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("hospCode", request.getParameter("hospCode"));
				page.getConditions().put("drugName", request.getParameter("drugName"));
				return anaDruginfoManager.getAnaDelByHospDrugWithMon(page, "1");
			}
			
			/**
			 * 
			 *@category  
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportAnaDelByHospDrugWithMon")
			@ResponseBody
			public Pagination exportAnaDelByHospDrugWithMon(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("hospCode", request.getParameter("hospCode"));
				page.getConditions().put("drugName", request.getParameter("drugName"));
				page.getConditions().put("noPage", "noPage");
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaDelByHospDrugWithMon(page, "1");
					
					String[] headers = {"医疗机构名称","通用名","剂型","规格","转换系数","单位","生产企业","药品分类","采购总金额(万元)","配送金额(万元)", "入库金额(万元)",  "配送率", "入库率" };
					String[] alias = {"hosp_name","drug_name","form_name","spec_name","factor","unit_name","prod_compname","drug_cat","total_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, title, headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
			/**
			 * @category 跳 配送企业-生产企业-药品
			 * @date 2015年12月1日10:55:55
			 * @author wangbing
			 * @return
			 */
			@RequestMapping("/toAnaDelByProdCompDrugWithMon")
			public String toAnaDelByProdCompDrugWithMon() {
				request.setAttribute("delCompCode", request.getParameter("delCompCode"));
				request.setAttribute("date", request.getParameter("date"));
				request.setAttribute("prodCompCode", request.getParameter("prodCompCode"));
				try {
					request.setAttribute("delCompName", new String(request.getParameter("delCompName").getBytes("iso8859-1"),"utf-8"));
					request.setAttribute("prodCompName", new String(request.getParameter("prodCompName").getBytes("iso8859-1"),"utf-8"));
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
				request.setAttribute("total", request.getParameter("total"));
				request.setAttribute("del", request.getParameter("del"));
				request.setAttribute("recp", request.getParameter("recp"));
				return "/pro/base/anaDruginfo/anaDelByProdCompDrugWithMon";
			}
			
			
			/**
			 * 
			 *@category 获取   配送企业-生产企业-药品   列表数据
			 *@author lil
			 *@date 2015年12月3日 上午10:06:50
			 *@param 
			 *@return Pagination
			 */
			@RequestMapping("/getAnaDelByProdCompDrugWithMon")
			@ResponseBody
			public Pagination getAnaDelByProdCompDrugWithMon(){
				Pagination page = new Pagination(request);
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("prodCompCode", request.getParameter("prodCompCode"));
				page.getConditions().put("drugName", request.getParameter("drugName"));
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("areaId", areaId);
				}
				return anaDruginfoManager.getAnaDelByProdCompDrugWithMon(page, "1");
			}
			
			/**
			 * 
			 *@category  
			 *@author wangbing
			 *@date 2015年12月22日14:46:06
			 *Pagination
			 */
			@RequestMapping("exportAnaDelByProdCompDrugWithMon")
			@ResponseBody
			public Pagination exportAnaDelByProdCompDrugWithMon(HttpServletResponse response){
				Pagination page = new Pagination(request);
				String title = "统计汇总";
				page.getConditions().put("delCompCode", request.getParameter("delCompCode"));
				page.getConditions().put("date", request.getParameter("date"));
				page.getConditions().put("prodCompCode", request.getParameter("prodCompCode"));
				page.getConditions().put("drugName", request.getParameter("drugName"));
				page.getConditions().put("noPage", "noPage");
				SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				if(Constants.HSZX==user.getType()){
					StdHealthbureau shb = user.getInfo();
					String areaId = shb.getArea().getAreaid();
					page.getConditions().put("areaId", areaId);
				}
				try {
					title = ExcelUtil.processFileName(request, title);  
					response.addHeader("Content-Disposition", "attachment;filename="+title+".xls");
					OutputStream os= new BufferedOutputStream(response.getOutputStream());  
					response.setContentType("application/vnd.ms-excel;charset=utf-8");  
					page = anaDruginfoManager.getAnaDelByProdCompDrugWithMon(page, "1");
					
					String[] headers = {"生产企业名称","通用名","剂型","规格","转换系数","单位","药品分类","采购总金额(万元)","配送金额(万元)", "入库金额(万元)",  "配送率", "入库率" };
					String[] alias = {"prod_comp_name","form_name","spec_name","factor","unit_name","drug_name","drug_cat","total_amount", "del_amount", "recp_amount", "del_ratio", "recp_ratio"};
					ExcelUtil.exportExcel(page, os, title, headers, alias);
					page.setSuccess(true);
				} catch (Exception e) {
					page.setSuccess(false);
					e.printStackTrace();
				}
				return page;
			}
			
}
